using Microsoft.AspNetCore.Mvc;
using star_questionnair.Models;
using star_questionnair.Services;

namespace star_questionnair.Controllers;

[Route("differenceChoiceQuestionAnalysis")]
[ApiController]
public class DifferenceChoiceQuestionAnalysisController : ControllerBase
{
    private readonly IDifferenceChoiceQuestionAnalysisService _differenceAnalysisService;

        public DifferenceChoiceQuestionAnalysisController(IDifferenceChoiceQuestionAnalysisService differenceAnalysisService)
        {
            _differenceAnalysisService = differenceAnalysisService;
        }

        // 单个问题 性别差异分析
        [HttpGet("differenceGender/{questionId}")]
        public async Task<ActionResult<Dictionary<string, Dictionary<bool, int>>>> DifferenceGender(int questionId)
        {
            var result = await _differenceAnalysisService.GetGenderDifferenceAsync(questionId);
            if (result != null)
                return Ok(new { success = true, data = result });
            return Ok(new { message = "No words found." });
        }

        // 单个问题 年龄差异化分析
        [HttpGet("differenceAge/{questionId}")]
        public async Task<ActionResult<Dictionary<string, Dictionary<string, int>>>> DifferenceAge(int questionId)
        {
            var result = await _differenceAnalysisService.GetAgeDifferenceAsync(questionId);
            if (result != null)
                 return Ok(new { success = true, data = result });
            return Ok(new { message = "No words found." });
        }

        // 单个问题 公司差异化分析
        [HttpGet("differenceEnterprise/{questionId}")]
        public async Task<ActionResult<Dictionary<string, Dictionary<string, int>>>> DifferenceEnterprise(int questionId)
        {
            var result = await _differenceAnalysisService.GetEnterpriseDifferenceAsync(questionId);
            if (result != null)
                return Ok(new { success = true, data = result });
            return Ok(new { message = "No words found." });
        }

        // 单个问题 职位差异化分析
        [HttpGet("differenceRole/{questionId}")]
        public async Task<ActionResult<Dictionary<string, Dictionary<string, int>>>> DifferenceRole(int questionId)
        {
            var result = await _differenceAnalysisService.GetRoleDifferenceAsync(questionId);
            if (result != null)
                return Ok(new { success = true, data = result });
            return Ok(new { message = "No words found." });
        }

        // 整个问卷 性别差异分析
        [HttpGet("differenceGenderBig/{questionnaireId}")]
        public async Task<ActionResult<Dictionary<bool, int>>> DifferenceGenderBig(int questionnaireId)
        {
            var result = await _differenceAnalysisService.GetGenderDifferenceBigAsync(questionnaireId);
            if (result != null)
                return Ok(new { success = true, data = result });
            return Ok(new { message = "No words found." });
        }

        // 整个问卷 年龄差异分析
        [HttpGet("differenceAgeBig/{questionnaireId}")]
        public async Task<ActionResult<Dictionary<string, int>>> DifferenceAgeBig(int questionnaireId)
        {
            var result = await _differenceAnalysisService.GetAgeDifferenceBigAsync(questionnaireId);
            if (result != null)
                return Ok(new { success = true, data = result });
            return Ok(new { message = "No words found." });
        }

        // 整个问卷 公司差异分析
        [HttpGet("differenceEnterpriseBig/{questionnaireId}")]
        public async Task<ActionResult<Dictionary<string, int>>> DifferenceEnterpriseBig(int questionnaireId)
        {
            var result = await _differenceAnalysisService.GetEnterpriseDifferenceBigAsync(questionnaireId);
            if (result != null)
                return Ok(new { success = true, data = result });
            return Ok(new { message = "No words found." });
        }

        // 整个问卷 职位差异分析
        [HttpGet("differenceRoleBig/{questionnaireId}")]
        public async Task<ActionResult<Dictionary<string, int>>> DifferenceRoleBig(int questionnaireId)
        {
            var result = await _differenceAnalysisService.GetRoleDifferenceBigAsync(questionnaireId);
            if (result != null)
                return Ok(new { success = true, data = result });
            return Ok(new { message = "No words found." });
        }
}